import * as api from '../../api/department';

export default {
    namespaced: true,
    state: {
        departmentList: [],
        managerList: [],
    },
    mutations: {
        SET_DEPARTMENT_LIST (state, newValue) {
            state.departmentList = newValue;
        },
        SET_MANAGER_LIST (state, newValue) {
            state.managerList = newValue;
        },
    },
    actions: {
        async updateDepartmentList (ctx) {
            const res = await api.getDepartmentInfo();
            ctx.commit('SET_DEPARTMENT_LIST', res.data.data.depts);
        },
        async updateManagerList (ctx) {
            const res = await api.getManagerList();
            ctx.commit('SET_MANAGER_LIST', res.data.data);
        },
    },
}
